package com.example.demo.controller;

import com.example.demo.drools.base.Result;
import com.example.demo.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

    @Autowired
    private DemoService demoService;

    /**
     * 测试drools，借用领取优惠券场景，使用规则引擎实现“领取的数量不能超过2张”
     * @param currentReceivedNum 当前领取数量
     * @return
     */
    @PostMapping(value = "/demo/drools/test")
    public Result test(@RequestParam(name = "currentReceivedNum") Integer currentReceivedNum) {
        return demoService.test(currentReceivedNum);
    }
}
